package com.csjbot.blackgaga.feature.nearbyservice;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.csjbot.blackgaga.R;
import com.csjbot.blackgaga.ai.NearByAI;
import com.csjbot.blackgaga.base.BaseFullScreenActivity;
import com.csjbot.blackgaga.base.BasePresenter;
import com.csjbot.blackgaga.router.BRouterPath;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by xiasuhuei321 on 2017/10/17.
 * author:luo
 * e-mail:xiasuhuei321@163.com
 */

@Route(path = BRouterPath.NEAR_BY_MAIN)
public class NearByActivity extends BaseFullScreenActivity {


    @BindView(R.id.ll_food)
    LinearLayout mLlFood;
    @BindView(R.id.ll_scenic)
    LinearLayout mLlScenic;
    @BindView(R.id.ll_hotel)
    LinearLayout mLlHotel;
    @BindView(R.id.ll_relax)
    LinearLayout mLlRelax;
    @BindView(R.id.ll_share_bike)
    LinearLayout mLlShareBike;
    @BindView(R.id.ll_supermarket)
    LinearLayout mLlSupermarket;
    @BindView(R.id.ll_atm)
    LinearLayout mLlAtm;
    @BindView(R.id.ll_wc)
    LinearLayout mLlWc;
    @BindView(R.id.ll_fast_hotel)
    LinearLayout mLlFastHotel;
    @BindView(R.id.ll_cyber_bar)
    LinearLayout mLlCyberBar;
    @BindView(R.id.ll_underground)
    LinearLayout mLlUnderground;
    @BindView(R.id.ll_gas_station)
    LinearLayout ll_gas_station;

    NearByAI mAI;


    @Override
    protected BasePresenter getPresenter() {
        return null;
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_nearby;
    }

    @Override
    public void afterViewCreated(Bundle savedInstanceState) {
        getTitleView().setBackVisibility(View.VISIBLE);
    }

    @Override
    public void init() {
        super.init();
        mAI = NearByAI.newInstance();
        mAI.initAI(this);
    }

    @Override
    protected CharSequence initChineseSpeakText() {
        return "请问您想去周边哪些地方？请说出想要查询的周边内容。";
    }

    @Override
    protected CharSequence initEnglishSpeakText() {
        return null;
    }

    @Override
    protected boolean onSpeechMessage(String text, String answerText) {
        if (super.onSpeechMessage(text, answerText)) {
            return false;
        }
        NearByAI.Intent intent = mAI.getIntent(text);
        if (intent != null) {
            mAI.handleIntent(intent);
        } else {
            prattle(answerText);
        }
        return true;
    }

    @Override
    public boolean isOpenTitle() {
        return true;
    }

    @Override
    public boolean isOpenChat() {
        return true;
    }


    @OnClick({R.id.ll_food, R.id.ll_scenic, R.id.ll_hotel, R.id.ll_relax, R.id.ll_share_bike, R.id.ll_supermarket, R.id.ll_atm, R.id.ll_wc, R.id.ll_fast_hotel, R.id.ll_cyber_bar, R.id.ll_underground, R.id.ll_gas_station})
    public void onViewClicked(View view) {
        Intent intent = new Intent(NearByActivity.this, PoiSearchActivity.class);
        switch (view.getId()) {
            case R.id.ll_food:
                intent.putExtra(PoiSearchActivity.KEYWORD, "美食");
                startActivity(intent);
                break;
            case R.id.ll_scenic:
                intent.putExtra(PoiSearchActivity.KEYWORD, "景点");
                startActivity(intent);
                break;
            case R.id.ll_hotel:
                intent.putExtra(PoiSearchActivity.KEYWORD, "酒店");
                startActivity(intent);
                break;
            case R.id.ll_relax:
                intent.putExtra(PoiSearchActivity.KEYWORD, "休闲娱乐");
                startActivity(intent);
                break;
            case R.id.ll_share_bike:
                intent.putExtra(PoiSearchActivity.KEYWORD, "共享单车");
                startActivity(intent);
                break;
            case R.id.ll_supermarket:
                intent.putExtra(PoiSearchActivity.KEYWORD, "超市");
                startActivity(intent);
                break;
            case R.id.ll_atm:
                intent.putExtra(PoiSearchActivity.KEYWORD, "ATM");
                startActivity(intent);
                break;
            case R.id.ll_wc:
                intent.putExtra(PoiSearchActivity.KEYWORD, "厕所");
                startActivity(intent);
                break;
            case R.id.ll_fast_hotel:
                intent.putExtra(PoiSearchActivity.KEYWORD, "快捷酒店");
                startActivity(intent);
                break;
            case R.id.ll_cyber_bar:
                intent.putExtra(PoiSearchActivity.KEYWORD, "网吧");
                startActivity(intent);
                break;
            case R.id.ll_underground:
                intent.putExtra(PoiSearchActivity.KEYWORD, "地铁");
                startActivity(intent);
                break;
            case R.id.ll_gas_station:
                intent.putExtra(PoiSearchActivity.KEYWORD, "加油站");
                startActivity(intent);
                break;
        }
    }

    public void goPoiSearchAct(String text) {
        Intent intent = new Intent(NearByActivity.this, PoiSearchActivity.class);
        intent.putExtra(PoiSearchActivity.KEYWORD, text);
        startActivity(intent);
    }
}
